﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace XMLSchemaExtractor
{
    class DNonPrimeAttribute : ORASSDrawing
    {
        private DEntity _entity;
        private string _attributeName;

        private int _x;
        private int _y;

        public DNonPrimeAttribute(DEntity entity, string attributeName, int n, int pos)
        {
            _entity = entity;
            _attributeName = attributeName;
            _x = entity.x + pos * 50 / n;
            _y = entity.y +40;
        }
       

  

        public void Draw(Graphics graphic)
        {
            Pen myPen = new Pen(Color.Black,1);
            // need to change to height below entity and x ,y with respect of each attribute
            Rectangle myRectangle = new Rectangle(_x,_y, 14, 14);
            graphic.DrawEllipse(myPen, myRectangle);
            Brush myBrush = new SolidBrush(Color.Black);
            DrawText(graphic, myBrush);
            DrawLine(graphic, myPen);
            myPen.Dispose();
            myBrush.Dispose();
        }
        public void DrawText(Graphics graphic, Brush brush)
        {
            Font font = new Font("Times New Roman", 8, FontStyle.Regular);
            graphic.DrawString(_attributeName, font, brush, _x-5, _y+15);

        }
        public void DrawLine(Graphics graphic,Pen pen)
        {
            pen.StartCap = LineCap.ArrowAnchor;
            pen.EndCap = LineCap.Square;
            graphic.DrawLine(pen, new Point(_x + 5, _y), new Point(_x, _entity.y + 20));
        }
    }
}
